home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / srtsltn / data1.cab / Target / Samples / ActiveX / VB / Main.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-08-05  |  6.4 KB  |  205 lines

  1. VERSION 5.00
  2. Object = "{F43F7176-5DB4-11D1-A549-0020AF498497}#1.0#0"; "SortSolX.ocx"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  4. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
  5. Begin VB.Form SosoForm 
  6.    Caption         =   "Sort Solution ActiveX Demo"
  7.    ClientHeight    =   2925
  8.    ClientLeft      =   60
  9.    ClientTop       =   315
  10.    ClientWidth     =   6615
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2925
  13.    ScaleWidth      =   6615
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.CommandButton BtnAbort 
  16.       Caption         =   "&Abort"
  17.       Height          =   495
  18.       Left            =   1800
  19.       TabIndex        =   8
  20.       Top             =   960
  21.       Width           =   1335
  22.    End
  23.    Begin ComctlLib.ProgressBar ProgressBarMerge 
  24.       Height          =   255
  25.       Left            =   1560
  26.       TabIndex        =   7
  27.       Top             =   2400
  28.       Width           =   4815
  29.       _ExtentX        =   8493
  30.       _ExtentY        =   450
  31.       _Version        =   327682
  32.       Appearance      =   0
  33.    End
  34.    Begin ComctlLib.ProgressBar ProgressBarSort 
  35.       Height          =   255
  36.       Left            =   1560
  37.       TabIndex        =   6
  38.       Top             =   2040
  39.       Width           =   4815
  40.       _ExtentX        =   8493
  41.       _ExtentY        =   450
  42.       _Version        =   327682
  43.       Appearance      =   0
  44.    End
  45.    Begin MSComDlg.CommonDialog CommonDialog1 
  46.       Left            =   5040
  47.       Top             =   840
  48.       _ExtentX        =   847
  49.       _ExtentY        =   847
  50.       _Version        =   327681
  51.    End
  52.    Begin VB.CommandButton BtnBrowse 
  53.       Caption         =   "&Browse..."
  54.       Height          =   375
  55.       Left            =   5040
  56.       TabIndex        =   3
  57.       Top             =   360
  58.       Width           =   1335
  59.    End
  60.    Begin VB.CommandButton BtnRun 
  61.       Caption         =   "&Run Profile..."
  62.       Height          =   495
  63.       Left            =   240
  64.       TabIndex        =   2
  65.       Top             =   960
  66.       Width           =   1335
  67.    End
  68.    Begin VB.TextBox ProfileName 
  69.       Height          =   375
  70.       Left            =   240
  71.       TabIndex        =   0
  72.       Top             =   360
  73.       Width           =   4695
  74.    End
  75.    Begin VB.Label Label3 
  76.       Caption         =   "Merge:"
  77.       Height          =   255
  78.       Left            =   240
  79.       TabIndex        =   5
  80.       Top             =   2400
  81.       Width           =   1095
  82.    End
  83.    Begin VB.Label Label1 
  84.       Caption         =   "Sort:"
  85.       Height          =   255
  86.       Left            =   240
  87.       TabIndex        =   4
  88.       Top             =   2040
  89.       Width           =   1215
  90.    End
  91.    Begin SORTSOLXLib.SortSol SortSol 
  92.       Left            =   5640
  93.       Top             =   840
  94.       _Version        =   65536
  95.       _ExtentX        =   873
  96.       _ExtentY        =   873
  97.       _StockProps     =   0
  98.       Profile         =   $"Main.frx":0000
  99.    End
  100.    Begin VB.Label Pro 
  101.       Caption         =   "Profile:"
  102.       Height          =   255
  103.       Left            =   240
  104.       TabIndex        =   1
  105.       Top             =   120
  106.       Width           =   3255
  107.    End
  108. Attribute VB_Name = "SosoForm"
  109. Attribute VB_GlobalNameSpace = False
  110. Attribute VB_Creatable = False
  111. Attribute VB_PredeclaredId = True
  112. Attribute VB_Exposed = False
  113. ' Initially disable the "Run" button (no profile loaded yet!
  114. Private Sub Form_Load()
  115.     BtnRun.Enabled = False
  116.     BtnAbort.Enabled = False
  117. End Sub
  118. ' Handle the browse button to display a File Open Common Control
  119. Private Sub BtnBrowse_Click()
  120.     CommonDialog1.CancelError = True
  121.     On Error GoTo ErrHandler
  122.     CommonDialog1.Filter = "Profiles (*.ssp)|*.ssp"
  123.     CommonDialog1.ShowOpen
  124.     ProfileName = CommonDialog1.filename
  125.     Exit Sub
  126. ErrHandler:
  127.     Exit Sub
  128. End Sub
  129. ' Abort the Sort
  130. Private Sub BtnAbort_Click()
  131.     SortSol.Aborted = True
  132. End Sub
  133. ' Handle the "Run" button
  134. Private Sub BtnRun_Click()
  135.     BtnRun.Enabled = False
  136.     ' Handle all errors (including COM (ActiveX) errors) in one common error handler
  137.     On Error GoTo Handler
  138.     ' Reset the progress bars
  139.     ProgressBarSort.Value = 0
  140.     ProgressBarMerge.Value = 0
  141.     ' Get the name from the edit field and load the profile
  142.     ' This will raise an OLE error if anything goes wrong
  143.      
  144.     SortSol.LoadProfile (ProfileName)
  145.     ' Allow abort
  146.     SortSol.Aborted = False
  147.     BtnAbort.Enabled = True
  148.     ' Execute the sort
  149.     ' This function will return only in case of an error
  150.     ' or when the sort finishes
  151.     SortSol.Sort
  152.     ' We will only get here when no error occured
  153.     BtnAbort.Enabled = False
  154.     BtnRun.Enabled = True
  155.     MsgBox "Sort completed in " & CLng(SortSol.StatsSortTime + SortSol.StatsMergeTime) & " seconds.", , "Sort Solution"
  156.     Exit Sub
  157. Handler:
  158.     ' Handle all kinds of errors with a simply message box
  159.     ' (This is only a D E M O ...
  160.     MsgBox SortSol.ErrorMsg, , "Error"
  161.     ProgressBarSort.Value = 0
  162.     ProgressBarMerge.Value = 0
  163.     BtnAbort.Enabled = False
  164.     BtnRun.Enabled = True
  165. End Sub
  166. ' This sub gets called when the user changes the contents
  167. ' of the edit field. If the field is empty, the "Run" button
  168. ' is disabled, else enabled
  169. Private Sub ProfileName_Change()
  170.     If Len(ProfileName) > 0 Then
  171.         BtnRun.Enabled = True
  172.     Else
  173.         BtnRun.Enabled = False
  174.     End If
  175. End Sub
  176. ' This event is fired when the sort starts. Change the cursor
  177. ' to an hour glass to indicate the "working" mode to the user
  178. Private Sub SortSol_BeginSortPhase(ByVal SType As Integer)
  179.     MousePointer = vbArrowHourglass
  180. End Sub
  181. Private Sub SortSol_FinishSortPhase()
  182. ' Nothing to do here
  183. End Sub
  184. Private Sub SortSol_BeginMergePhase()
  185. ' Nothing to do here
  186. End Sub
  187. Private Sub SortSol_FinishMergePhase()
  188. ' Nothing to do here
  189. End Sub
  190. Private Sub SortSol_FinishedSort()
  191.     MousePointer = vbDefault
  192. End Sub
  193. ' The merge completed another percent
  194. Private Sub SortSol_MergePercentage(ByVal Percentage As Integer)
  195.     ProgressBarMerge.Value = Percentage
  196.     ' Keep the app responding
  197.     DoEvents
  198. End Sub
  199. ' The sort completed another percent
  200. Private Sub SortSol_SortPercentage(ByVal Percentage As Integer)
  201.     ProgressBarSort.Value = Percentage
  202.     ' Keep the app responding
  203.     DoEvents
  204. End Sub
  205.